package be.kuleuven.thesis.parsers;

import java.util.HashMap;
import java.util.Map;

public class VariantFeature {
	private String chrom;
	private Integer position;
	private String id;
	private String refAllele;
	private String altAllele;
	private Float quality;
	//private String filter;
	private String info;
	private String format;
	//private ArrayList<String> strainNames;
	private HashMap<String,String> sampleGenotypes;
	
	public VariantFeature() {
		
	}
	
	public VariantFeature(String chrom, Integer position, String localId, String refAllele, String altAllele, Float quality,
			String info, String format, HashMap<String,String> sampleGenotypes){
		
		/*if(localId == ".")
			setLocalId();*/
		
		id = localId;
		this.chrom = chrom;
		this.position = position;
		this.refAllele = refAllele;
		this.altAllele = altAllele;
		this.quality = quality;
		this.info = info;
		this.format = format;
		this.sampleGenotypes = sampleGenotypes;
		
	}
	
	
	public String chrom(){
		return chrom;
	}
	
	public int position(){
		return position;
	}
	
	/*private void setLocalId(){
		id = chrom + position + refAllele;
	}*/
	
	public String localId(){
		return id;
	}
	
	public String refAllele(){
		return refAllele;
	}
	
	public String altAllele(){
		return altAllele;
	}
	
	public Float quality(){
		return quality;
	}
	
	public HashMap<String,String> infoHashMap(){
		Map<String, String> varInfo = new HashMap<String, String>() ;
		String[] keyValues = info.split(";");
		for(String keyValue : keyValues){
			String[] keyAndValue = keyValue.split("=");
			varInfo.put(keyAndValue[0], keyAndValue[1]);
		}
			
		return (HashMap<String, String>) varInfo;
	}
	
	public String[] info(){
		String[] keyValues = info.replace('=', ':').split(";");
		return keyValues;
	}
	
	public String format(){
		return format;
	}
	
	public HashMap<String,String> sampleAndGenotypes(){
		return sampleGenotypes;
	}
	
	public String[] getSampleNames(){
		String[] names = new String[sampleGenotypes.size()];
		sampleGenotypes.keySet().toArray(names);
		return names;
	}

}
